<template>
  <div class="zoom-control">
    <!-- <div class="scale-btns">
       <span class="zoom-btn" @click="substractScale">
        <a-icon-font type="iconjianhao"/>
      </span>
        <span class="zoom-btn" @click="addScale">
        <a-icon-font type="iconjiahao"/>
      </span>
    </div> -->
    <a-slider
      v-model="zoomScale"
      style="margin: 10px 6px; width: 100%;"
      :default-value="100"
      :min="50"
      :max="200"
      :step="25"
      @change="scaleChange"
    />
    <span class="vertical-divider"></span>
    <span class="zoom-scale">{{ zoomScale }}%</span>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

@Component({
  components: {},
})
export default class ZoomControl extends Vue {
  private zoomScale: number = 100

  private addScale() {
    if (this.zoomScale < 125) {
      this.zoomScale += 5
      this.$nextTick(() => {
        this.$emit('scale', this.zoomScale)
      })
    }
  }

  public addNodeTest() {
    this.$message.warning('暂无该功能！')
  }

  private scaleChange() {
    this.$nextTick(() => {
      this.$emit('scale', this.zoomScale)
    })
  }

  private substractScale() {
    if (this.zoomScale > 75) {
      this.zoomScale -= 5
      this.$nextTick(() => {
        this.$emit('scale', this.zoomScale)
      })
    }
  }
}
</script>

<style scoped lang="less">
.zoom-control {
  align-items: center;
  background: #fff;
  border: 1px solid #e9e9e9;
  border-radius: 12px;
  bottom: 15px;
  box-sizing: border-box;
  display: flex;
  height: 24px;
  justify-content: flex-end;
  overflow: hidden;
  padding: 0 4px;
  position: absolute;
  right: 15px;
  transition: width 0.3s;
  user-select: none;
  // width: 50px;
  width: 208px;
  z-index: 100;

  // &:hover {
  //   width: 208px;
  //   // width: 108px;
  // }

  .vertical-divider {
    background-color: #999;
    height: 16px;
    margin: 0 8px;
    width: 1px;
  }

  .zoom-scale {
    color: #5d637e;
    display: inline-block;
    flex-shrink: 0;
    height: 20px;
    line-height: 20px;
    position: relative;
    text-align: center;
    width: 39px;
  }

  .scale-btns {
    align-items: center;
    display: flex;
    height: 100%;
    justify-content: space-around;
    width: 64px;

    .zoom-btn {
      border-radius: 1px;
      cursor: pointer;
      display: inline-block;
      flex-shrink: 0;
      height: 18px;
      line-height: 18px;
      padding: 0 2px;
      width: 18px;

      &:hover {
        background-color: #f1f1f1;
      }
    }
  }
}
</style>
